<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
    

   /* function* next_id(max) {
        var current_id = 0;
        while(current_id <max){
            yield current_id;
            current_id ++;
        }
        return;
    }*/
    'use strict';
    function* next_id() {   
       let id =1;
        while (true){yield id++;} 
    }
    var
    x,
    pass = true,
    g = next_id();
for (x = 1; x < 100; x ++) {
    if (g.next().value !== x) {
        pass = false;
        console.log('测试失败!');
        break;
    }
}
if (pass) {
    console.log('测试通过!');
}
</script>
</body>
</html>